package com.redrose.rxandroiddemo.splash;

import android.text.TextUtils;
import android.widget.Button;


import androidx.lifecycle.Observer;

import com.redrose.rxandroiddemo.R;
import com.redrose.rxandroiddemo.base.BaseActivity;
import com.redrose.rxandroiddemo.databinding.ActivitySplashBinding;
import com.redrose.rxandroiddemo.main.activity.MainActivity;

public class SplashActivity extends BaseActivity<ActivitySplashBinding> {

    private Button mLoginButton;
    private LoginViewModel mLoginViewModel;

    @Override
    protected void initEvent() {

    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_splash;
    }

    @Override
    protected void initView() {
        mLoginButton = mBinding.loginMain;
        mLoginViewModel = getActivityViewModel(LoginViewModel.class);
        mBinding.setViewModel(mLoginViewModel);
    }

    @Override
    protected void initData() {
        mLoginViewModel.getLoginLiveData().observe(this, mObserver);
    }

    private final Observer<String> mObserver = flag -> {
        if (TextUtils.equals("login",flag)) {
            openActivity(MainActivity.class);
        }
    };


}
